package com.example.photography.fragment.community;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.fastjson.JSONObject;
import com.example.photography.R;
import com.example.photography.adapter.community.CommunityAdapter;
import com.example.photography.bean.CommunityBean;
import com.example.photography.common.BaseFragment;
import com.loopj.android.http.RequestParams;

import java.util.Objects;

import butterknife.BindView;

import static com.example.photography.Activity.Store_Activity.getJson;

public class Community_Home extends BaseFragment {
    private CommunityBean communityBean;

    @BindView(R.id.rc_home)
    RecyclerView rcHome;

    @Override
    protected RequestParams getParams() {
        return null;
    }

    @Override
    protected String getUrl() {
        return null;
    }

    @Override
    protected void initData(String content) {
        String json = getJson(Objects.requireNonNull(getActivity()), "community_data.json");
        communityBean = JSONObject.parseObject(json, CommunityBean.class);
        initView();
    }
    private void initView() {
        CommunityAdapter communityAdapter = new CommunityAdapter(getActivity(), communityBean.getData());
        rcHome.setAdapter(communityAdapter);
        //设置布局管理者
        rcHome.setLayoutManager(new GridLayoutManager(getActivity(),1));
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_com_home;
    }

}
